﻿using AutoMapper;
using MediatR;
using SheepStorage.API.Application.Command.LambWeaningCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.LambWeaningHandler
{
    public class LambWeaningDeleteHandler:IRequestHandler<LambWeaningDeleteCommand,Results<int>>
    {
        private readonly ILambWeaningService _lambService;
        private readonly IMapper _mapper;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="lambService"></param>
        /// <param name="mapper"></param>
        public LambWeaningDeleteHandler(ILambWeaningService lambService, IMapper mapper)
        {
            _lambService = lambService;
            _mapper = mapper;
        }


        /// <summary>
        /// 批量删除/逻辑删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Results<int>> Handle(LambWeaningDeleteCommand request, CancellationToken cancellationToken)
        {
            var result = await _lambService.DeleteLambWeaning(request.LambWeaningId.ToArray());

            return Results<int>.DataResult(result);
        }
    }
}
